home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rjs.lha / RJS / Transport / tests / recho.C < prev    next >
C/C++ Source or Header  |  1991-06-14  |  527b  |  27 lines

  1. #include <iostream.h>
  2. #include "RJS/Transport.h"
  3. #include <osfcn.h>
  4. #include <libc.h>
  5.  
  6. int main(int argc, char *argv[]) 
  7. {
  8.   if (argc!=2) {
  9.     cerr << "usage: " << argv[0] << " host" << endl;
  10.     exit(1);
  11.   }
  12.  
  13.   RJS_InetAddress echo_address(argv[1],"echo","udp");
  14.   RJS_InetDatagram echo_server;
  15.  
  16.   echo_server.active();
  17.   echo_server.sendto("hello",5,echo_address); // send to server
  18.  
  19.   char buffer[512]; 
  20.   int nbr=echo_server.recv(buffer,512);    // get reply
  21.   buffer[nbr]=0;
  22.  
  23.   cout << "echo => " << buffer << endl;
  24.   exit(0);
  25. }
  26.  
  27.